package com.wanxi.servlet;

import com.wanxi.model.BrandModel;
import com.wanxi.service.BrandService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/findAll")
public class BrandFindAllServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //        1.乱码处理
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");
        //        2.得到前端的值
        //        3.封装对象
        //      4.调用服务逻辑层
        BrandService brandService = new BrandService();
        //      5.得到服务逻辑层的返回结果
        List<BrandModel> brandModelList = brandService.find();
        //        6.将返回结果返回给前端页面
        req.setAttribute("brandModelList", brandModelList);
        req.getRequestDispatcher("Brand.jsp").forward(req, resp);

    }
}
